package RPS;

public class RockPapersScissors
{
	public RockPapersScissors()
	{}
	
	public Result play(RPSEnum p1, RPSEnum p2)
	{
		//return Result.LOST;
		Result res = Result.LOST;
		
		switch(p1)
		{
		case ROCK:
			switch(p2)
			{
			case ROCK:
				res = Result.TIE;
				break;
			case PAPERS:
				res = Result.LOST;
				break;
			case SCISSORS:
				res = Result.WIN;
				break;
			default:
				break;
			}
			break;
			
		case PAPERS:
			switch(p2)
			{
			case ROCK:
				res = Result.WIN;
				break;
			case PAPERS:
				res = Result.TIE;
				break;
			case SCISSORS:
				res = Result.LOST;
				break;
			default:
				break;
			}
			break;
			
		case SCISSORS:
			switch(p2)
			{
			case ROCK:
				res = Result.LOST;
				break;
			case PAPERS:
				res = Result.WIN;
				break;
			case SCISSORS:
				res = Result.TIE;
				break;
			default:
				break;
			}
			break;
		}
		
		return res;
	}
	
	public Result play(Player p1, Player p2)
	{
		Result res = Result.LOST;
		int score1 = 0;
		int score2 = 0;
		switch(p1.getMoves(0))
		{
		case ROCK:
			switch(p2.getMoves(0))
			{
			case ROCK:
				res = Result.TIE;
				score1++;
				score2++;
				break;
			case PAPERS:
				res = Result.LOST;
				score2++;
				break;
			case SCISSORS:
				res = Result.WIN;
				score1++;
				break;
			default:
				break;
			}
			break;
			
		case PAPERS:
			switch(p2.getMoves(0))
			{
			case ROCK:
				res = Result.WIN;
				score1++;
				break;
			case PAPERS:
				res = Result.TIE;
				score1++;
				score2++;
				break;
			case SCISSORS:
				res = Result.LOST;
				score2++;
				break;
			default:
				break;
			}
			break;
			
		case SCISSORS:
			switch(p2.getMoves(0))
			{
			case ROCK:
				res = Result.LOST;
				score2++;
				break;
			case PAPERS:
				res = Result.WIN;
				score1++;
				break;
			case SCISSORS:
				res = Result.TIE;
				score1++;
				score2++;
				break;
			default:
				break;
			}
			break;
		}
		return res;
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
